#include "hplczkyspumpsendsystempacket.h"
#include "hplczkyspumpprotocoldata.h"
#include "common/hplczkyspfcid.h"
#include "hplczkysmakepacket.h"
#include "hplczkyscheckpacket.h"

namespace hplc
{
namespace zkys
{

HplcZkysPumpSendSystemPacket::HplcZkysPumpSendSystemPacket(HplcZkysPumpProtocolData &data)
{
    m_d = &data;
}

void HplcZkysPumpSendSystemPacket::setWorkMode(quint8 mode, quint8 flag)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_WORKMODE, mode, flag);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getWorkMode()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_WORKMODE);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setFlowCalibDataCMD(quint8 cmd)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_FLOWCALIB_DATA_CMD, cmd);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setFlowCalibData(float flow, float realFlow)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_FLOWCALIB_DATA, flow, realFlow);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getFlowCalibData()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_FLOWCALIB_DATA);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setFlowCalibLoadParam(float flow, float realFlow, float press)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_FLOWCALIB_LOADPARAM, flow, realFlow, press);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getFlowCalibLoadParam()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_FLOWCALIB_LOADPARAM);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setPressCalibDataCMD(quint8 cmd)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PRESSCALIB_DATA_CMD, cmd);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setPressCalibData(float press, float realPress)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PRESSCALIB_DATA, press, realPress);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getPressCalibData()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PRESSCALIB_DATA);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setPulseCompenDataCMD(quint8 cmd)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PULSECOMPEN_DATA_CMD, cmd);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setPulseCompenData(float position, float compenFactor)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PULSECOMPEN_DATA, position, compenFactor);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getPulseCompenData()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PULSECOMPEN_DATA);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setPulseCompenDebugCMD(quint8 cmd)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PULSECOMPEN_DEBUG_CMD, cmd);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getPulseCompenGearPos()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PULSECOMPEN_GEAR_POS);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setStepMotorCurrentRun(quint8 current)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_STEPMOTOR_IRUN, current);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getStepMotorCurrentRun()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_STEPMOTOR_IRUN);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setMotorCurrentDataCMD(quint8 cmd)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_MOTORCURRENT_DATA_CMD, cmd);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setMotorCurrentData(float flow, quint8 current)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_MOTORCURRENT_DATA, flow, current);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getMotorCurrentData()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_MOTORCURRENT_DATA);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::setPumpMaterial(quint8 type)
{
    m_d->m_maker->makePacket(SET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PUMPMATERIAL, type);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getPumpMaterial()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_PUMPMATERIAL);
    m_d->m_checker->sendRetry();
}

void HplcZkysPumpSendSystemPacket::getCurrentRpm()
{
    m_d->m_maker->makePacket(GET_PFC(PFC_PUMP_EXT_SYSTEM), (quint8)PFC_PES_CURRENTRPM);
    m_d->m_checker->sendRetry();
}

} // zkys
} // hplc
